using System.Windows;
using ErpManager.WPF.ViewModels;
using ErpManager.WPF.Services;

namespace ErpManager.WPF.Views
{
    public partial class LoginWindow : Window
    {
        public LoginWindow()
        {
            InitializeComponent();
            
            var dbContext = new ApplicationDbContext();
            var authService = new AuthenticationService(dbContext);
            DataContext = new LoginViewModel(authService);

            // 处理PasswordBox的密码绑定
            PasswordBox.PasswordChanged += (s, e) =>
            {
                if (DataContext is LoginViewModel viewModel)
                {
                    viewModel.Password = PasswordBox.Password;
                }
            };
        }
    }
}
